import { apiClient } from "./api";

export const communityService = {
  // === 帖子相关 ===
  getAllPosts: () => apiClient.get("/posts"),
  getPostById: (id) => apiClient.get(`/posts/${id}`),
  createPost: (post) => apiClient.post("/posts", post),
  updatePost: (id, post) => apiClient.put(`/posts/${id}`, post),
  deletePost: (id) => apiClient.delete(`/posts/${id}`),
  getCommentCount: (postId) => apiClient.get(`/posts/${postId}/comment-count`),

  // === 评论相关 ===
  getCommentsByPost: (postId) => apiClient.get(`/comments/post/${postId}`),
  getRepliesByParent: (parentId) =>
    apiClient.get(`/comments/reply/${parentId}`),
  addComment: (comment) => apiClient.post("/comments", comment),
  deleteComment: (id) => apiClient.delete(`/comments/${id}`),
};
